/*
 * @Author: your name
 * @Date: 2020-05-03 18:30:17
 * @LastEditTime: 2020-10-30 10:38:33
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /yigo/src/Pages/MineScreen.js
 */
import React, { Component } from 'react'
import { View, Text , Platform, Alert, TouchableOpacity, StyleSheet, DeviceEventEmitter, Image} from 'react-native'
import { connect } from 'react-redux'
import {uploadFile} from '../Actions/UserActions' 
import {Base64,checkUpdate } from '../Utils/Util'
import Swiper from 'react-native-swiper'
// import {ImageItem} from '../Pages/HomePageScreen'
// import Icon1 from 'react-native-vector-icons/AntDesign';

import { uploadFiles } from '../Utils/FileManager'

let data = [
  {title:'注册美食入口',icon:'apple1'},
  {title:'设置',icon:'apple1'},

];

let data0 = [
  // {title:'注册美食入口',icon:'apple1'},
  {title:'设置',icon:'apple1'},

];
export class MineScreen extends Component {
  
  constructor(props) {
    super(props)
    this.state = {
      count:0
    };
  }
  
    upload = () => {
      // Base64().then((info) => {
      //   this.props.uploadFile(info)
      // })
      uploadFiles()
    }

    changeTheme = () => {
      function color16(){//十六进制颜色随机
        var r = Math.floor(Math.random()*256);
        var g = Math.floor(Math.random()*256);
        var b = Math.floor(Math.random()*256);
        var color = '#'+r.toString(16)+g.toString(16)+b.toString(16);
        return color;
      }
      DeviceEventEmitter.emit('theme_change',color16())
    }

    onPress = (title) => {

      switch (title) {
        case '注册美食入口':
          this.props.navigation.navigate('FineFoodRegisterScreen')
          break;
          case '设置':
          this.props.navigation.navigate('SettingScreen')
          break;
        default:
          break;
      }
      
    }
    render() {  
      let array;
      if (userInfo.userType === 1) {
        array = data
      } else {
        array = data0
      }    
        return (
            <View style={{flex:1}}>
              <View style={{height:180}}>
              </View>
              
            {array.map((item,i) => {

              return (
                <View style={{justifyContent:'center', height:49}}>
                  <TouchableOpacity style={{flexDirection:'row',flex:1, justifyContent:'space-between', alignItems:'center', paddingLeft:10, paddingRight:10}} onPress={()=> this.onPress(item.title)}>
                      <View style={{flexDirection:'row', justifyContent:'center', alignItems:'center'}}>
                        <Text>{item.title}</Text>
                      </View>

                  </TouchableOpacity>
                  <View style={{backgroundColor:'#dcdcdc',height:1}}></View>
                </View>
              );
            })}
            </View>
        )
    }

}

const styles = StyleSheet.create({
  actionButtonIcon: {
    fontSize: 20,
    height: 22,
  }
})


const mapStateToProps = (state) => ({
    
})

const mapDispatchToProps = (dispatch, ownProps) => {  
  return {
    uploadFile:(paramter) => dispatch(uploadFile(paramter)),
    refreshToken:(paramter) => dispatch({paramter,type:'RefreshToken'})
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(MineScreen)
